package com.hall.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
public class TencentCloudUtils implements InitializingBean {
    //读取全局配置文件内容进行赋值
    @Value("${tencent.cloud.secretId}")
    private String secretId;

    @Value("${tencent.cloud.secretKey}")
    private String secretKey;

    @Value("${tencent.cloud.region}")
    private String region;

    @Value("${tencent.cloud.bucketName}")
    private String bucketName;

    @Value("${tencent.cloud.path}")
    private String path;
    //定义公开静态常量从而通过静态变量使用private变量，（为什么不直接用getset方法和spring声明周期有关）
    //OssServiceImpl中会用到。
    public static String SECRET_ID;
    public static String SECRE_KEY;
    public static String REGION;
    public static String BUCKET_NAME;
    public static String PATH;

    @Override
    public void afterPropertiesSet() throws Exception {
        SECRET_ID = secretId;
        SECRE_KEY = secretKey;
        REGION = region;
        BUCKET_NAME = bucketName;
        PATH = path;
    }
}
